<template>
  <div class="container">
    <el-card class="page-card">
      <el-form
        ref="form"
        :rules="$rules"
        :model="model"
        status-icon
        label-width="160px"
        class="grid-flex"
      >
        <el-form-item prop="SmsChannel" :label="$language.local('SmsChannel')">
          <el-radio-group v-model="model.SmsChannel">
            <el-radio :label="0">关闭</el-radio>
            <el-radio :label="1">阿里云认证</el-radio>
            <el-radio :label="2">腾云</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item
          prop="WmSignAppId"
          :label="$language.local('WmSignAppId')"
        >
          <xy-input v-model="model.WmSignAppId"></xy-input>
        </el-form-item>
        <el-form-item prop="WmSigniv" :label="$language.local('WmSigniv')">
          <xy-input v-model="model.WmSigniv"></xy-input>
        </el-form-item>
        <el-form-item prop="WmSignUrl" :label="$language.local('WmSignUrl')">
          <xy-input v-model="model.WmSignUrl"></xy-input>
        </el-form-item>
        <el-form-item
          prop="FrontUrl"
          class="textarea"
          :label="$language.local('FrontUrl')"
        >
          <xy-input v-model="model.FrontUrl"></xy-input>
        </el-form-item>
        <el-form-item
          prop="WmSignPublicKey"
          :label="$language.local('WmSignPublicKey')"
          class="textarea"
        >
          <xy-input
            type="textarea"
            :rows="4"
            :autosize="{ minRows: 5, maxRows: 6 }"
            v-model="model.WmSignPublicKey"
          ></xy-input>
        </el-form-item>
      </el-form>
      <div class="form-footer">
        <el-button type="primary" @click="onSubmit('form')">保存</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      model: {
        SmsChannel: "0",
        WmSignAppId: "",
        WmSigniv: "",
        WmSignUrl: "",
        WmSignPublicKey: "",
        FrontUrl: "",
      },
      api: "/api/systemSet",
    };
  },
  created() {
    this.getData();
  },
  methods: {
    async getData() {
      let response = await this.$http.get("/api/systemSet/GetModel/1?type=3");
      console.log(response);
      this.model = response.data.Data;
    },
    async onSubmit(formName) {
      let valided = await this.$refs[formName].validate().catch((err) => err);

      if (!valided) {
        return;
      }

      let response = await this.$http.post(
        "/api/systemSet/SmsChannelSet/1",
        null,
        this.model
      );
      console.log(response);
      if (response.data.Code == 200) {
        this.$message.success("修改成功");
      }
    },
  },
};
</script>

<style lang="less" scoped>
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  .page-card {
    width: 88%;
    padding: 1rem;
  }
  // .el-form {
  //   width: 60%;
  // }
}
</style>
